// Main 2connect2 AI headers
//
//

#include "isWin.h"
#include "threats.h"

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define SETCELL(board, x, y, cols, colour) (board [ y*cols + x ] = colour)

//#define TEST_ISWIN

//#define INFINITY (0x7FFFFFFF)
#define INFINITY 1000000

struct position {
	char *board;		// A char array of size cols * rows
	char nextMove;      // The player who is to move next: can be 'r' or 'b'
};

struct move {
	int8_t x;		// Column in which to make the move
	int8_t y;		// Row in which to make the move -- this effectively caches the legal row
	char colour;	// Colour of piece to drop: can be 'r' 'b' or 'g'
};

int eval ( struct position *p );

struct move doSearch (struct position *pos);

// Returns number of valid moves
int getMoves (struct position *pos, struct move *list);

// Don't think this is necessary
// int handleNoMove (struct position *pos);

void doMove (struct move *m, struct position *p);

void undoMove (struct move *m, struct position *p);

int alphaBeta (struct position *pos, int depth, int alpha, int beta);

struct move firstAlphaBeta (struct position *pos, int depth, int alpha, int beta);

char *createHashTable ();

int insert (char *board, int value);

// Returns 1 if the lookup was a hit, 0 otherwise
// Writes the value of the looked-up position into *value
int lookUp (char *board, int *value);

int getDepth ();

char *readBoardVector ();

void printMove (struct move *mv);


